package cn.leftsite.netty.test.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

/**
 * 扩展了MessageToMessageEncoder
 * @author wangjinqiang
 * @date 2019-05-30
 */
public class IntegerToStringEncoder extends MessageToMessageEncoder<Integer> {
    @Override
    protected void encode(ChannelHandlerContext ctx, Integer msg, List<Object> out) throws Exception {
        //将Integer 转换为String，并将其添加到List 中
        out.add(String.valueOf(msg));
    }
}
